package ar.edu.unq.wannaplay.tools;

import java.util.List;

import org.apache.wicket.spring.injection.annot.SpringBean;

import ar.edu.unq.wannaplay.dtos.EmployeeDTO;
import ar.edu.unq.wannaplay.dtos.ProjectDTO;
import ar.edu.unq.wannaplay.services.EmployeeService;

public class EmployeeSelector {
    @SpringBean(name = "service.employeeService")
    private EmployeeService employeeService;

    private List<EmployeeDTO> employees;

    private EmployeeDTO selectedEmployee;

    public EmployeeSelector withAllEmployeesFrom(final ProjectDTO project) {
        employees = project.getEmployees();
        return this;
    }

    public EmployeeSelector withAllEmployees() {
        employees = this.getEmployeeService().findAllDTOs();
        return this;
    }

    public EmployeeSelector withAllEmployeesThatDoesntWorkIn(final ProjectDTO project) {
        this.getEmployeeService().findAllDTOs().removeAll(project.getEmployees());
        return this;
    }

    public void removeEmployee(final EmployeeDTO employee) {
        this.getEmployees().remove(employee);
    }

    public void addEmployee(final EmployeeDTO employee) {
        this.getEmployees().add(employee);
    }

    // setters&getters
    public void setEmployeeService(final EmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    public EmployeeService getEmployeeService() {
        return employeeService;
    }

    public EmployeeDTO getSelectedEmployee() {
        return selectedEmployee;
    }

    public void setSelectedEmployee(final EmployeeDTO selectedEmployee) {
        this.selectedEmployee = selectedEmployee;
    }

    public List<EmployeeDTO> getEmployees() {
        return employees;
    }

    public void setEmployees(final List<EmployeeDTO> employees) {
        this.employees = employees;
    }
}
